<?php declare(strict_types=1);
namespace app\logic;

use app\exception\Failure;
use app\exception\Success;
use app\facade\model\AuthRule as FaAuthRuleModel;
use think\Exception;
use think\facade\Session;

class Menu  extends Base {

    public function del() : bool{
        $ruleId = $this->request->param('rule_id',0);
        $childCount = FaAuthRuleModel::childrenCount($ruleId);
        if($childCount >0){
            throw new Failure('has children');
        }
        $del = FaAuthRuleModel::del($ruleId);
        return $del;
    }


    public function update() : bool {
        //
        $menuData = $this->request->param();
        $update = FaAuthRuleModel::updateMenu($menuData);
        return $update;

    }

    public function create() : bool {
        //
        $menuData = $this->request->param();
        // 名称 校验
        $update = FaAuthRuleModel::createMenu($menuData);
        return $update;

    }

}